const redis = require('ioredis')

var cluster = new redis.Cluster(  
  [{  
    port: 7001,  
    host: '116.62.139.212'  
  }, {  
    port: 7002,  
    host: '116.62.139.212'  
  }, {  
    port: 7003,  
    host: '116.62.139.212'  
  }, {  
    port: 7004,  
    host: '116.62.139.212'  
  }, {  
    port: 7005,  
    host: '116.62.139.212'  
  }, {  
    port: 7006,  
    host: '116.62.139.212'  
  }]  
);  

cluster.set('foo', 'bar');
cluster.get('foo', function (err, result) {
  console.log(err);
});
 
// Or using a promise if the last argument isn't a function
cluster.get('foo').then(function (result) {
  console.log(result);
});

// const redis = require('redis')
// const redisConfig = {
//   host: '116.62.139.212',
//   port: '7001',
//   ttl: 1000 * 60 * 5,
//   password: 'u6^8LM*Zme7!Yl4!'
// }
// const redisClient = redis.createClient(redisConfig.port, redisConfig.host)
// redisClient.auth('', function () {
//   console.log("连接成功")
//   redisClient.on('ready', res => {
//     console.log('redis启动成功')
//   })
//   redisClient.on('connect', () => {
//     console.log('redis connect success')
//   })

//   redisClient.on('error', err => {
//     console.log('redis启动失败', err)
//   })
// })
// redisClient.set('foo','asdasd')
// redisClient.get('foo', function (err, result) {
//   console.log(result);
// });